transform

old TransE-like models
git clone https://esimon.eu/repos/transform.git
Log | Files | Refs | README

anisotropic homotheties.py (617B)


      1 #!/usr/bin/env python2
      2 
      3 from relations.base import *
      4 
      5 class Anisotropic_homotheties(Base_relation):
      6     """ Anisotropic homotheties class.
      7 
      8     This class has two parameters:
      9     P -- the homothetic centers
     10     S -- the scaling vectors
     11     """
     12     def __init__(self, rng, number, dimension, tag):
     13         """ Initialise the parameter. """
     14         parameters = [ ('P', (dimension,)), ('S', (dimension,)) ]
     15         super(Anisotropic_homotheties, self).__init__(rng, number, parameters, tag)
     16 
     17     def apply(self, inputs, p, s):
     18         """ Apply the given relations to a given input. """
     19         return p + (inputs-p)*s